<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>
                <div class="row">
                    <div class="col-sm-22 widget-container-col ui-sortable" id="widget-container-col-10">
                        <div class="widget-box ui-sortable-handle" id="widget-box-10">
                            <div class="widget-header widget-header-small">
                                <h5 class="widget-title smaller">报表信息</h5>
                            </div>
                            <div class="widget-body">
                                <div class="widget-main padding-6" style="overflow: hidden">
                                    <div class="tab-content">
                                        <div id="home" class="tab-pane active">
                                            <div class="col-xs-12">
                                                <!-- PAGE CONTENT BEGINS -->
                                                <form class="form-horizontal"
                                                      action="<?php echo site_url(X_URL . 'page/update'); ?>"
                                                      method="post" id="from1">
                                                    <?php echo csrf_hidden(); ?>
                                                    <input type="hidden" name="page_id"
                                                           value="<?php if (!empty($page_id)) {
                                                               echo $page_id;
                                                           } ?>">
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right"
                                                               for="form-field-1"> 报表标题 </label>
                                                        <div class="col-sm-9">
                                                            <input type="text" name="title" class="rcol-xs-10 col-sm-5"
                                                                   value="<?php if (isset($page)) {
                                                                       echo $page["title"];
                                                                   } ?>">
                                                            <input type="hidden" name="id"
                                                                   value="<?php if (isset($page)) {
                                                                       echo $page["id"];
                                                                   } ?>">
                                                            <span class="help-inline col-xs-12 col-sm-7">
                											     <span class="middle">请填写报表标题</span>
                											</span>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right"
                                                               for="form-field-1"> 对用户可见 </label>
                                                        <div class="col-sm-9">
                                                            <select id="user_id" name="user_id" class="select2">
                                                                <?php if (isset($users)) { ?>
                                                                    <?php foreach ($users as $key => $val) { ?>
                                                                        <option value="<?php echo $val['user_id']; ?>"
                                                                            <?php if (isset($page) && $val['user_id'] == $page['user_id']) { ?>
                                                                                selected="selected"
                                                                            <?php } ?>
                                                                        ><?php echo $val['user_name']; ?></option>
                                                                    <?php } ?>
                                                                <?php } ?>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="space-4"></div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right"
                                                               for="form-field-8">
                                                            报表详情 </label>
                                                        <div class="col-sm-9">
                                                            <textarea name="content" id="content"
                                                                      style="width:85%;height:400px;visibility:hidden;"><?php if (!empty($page['content'])) {
                                                                    echo $page['content'];
                                                                } ?></textarea>
                                                        </div>
                                                    </div>
                                                    <div class="space-4"></div>
                                                    <div class="col-md-offset-2 col-md-9">
                                                        <button class="btn btn-info" type="submit" id="subForm1">
                                                            <i class="icon-ok bigger-110"></i>
                                                            提交
                                                        </button>
                                                        &nbsp; &nbsp; &nbsp;
                                                        <button class="btn" type="reset">
                                                            <i class="icon-undo bigger-110"></i>
                                                            重置
                                                        </button>
                                                    </div>

                                                </form>
                                                <!-- PAGE CONTENT ENDS -->
                                            </div><!-- /.col -->
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /section:settings.box -->
                <div class="row">

                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div><!-- /.main-container -->
<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        var article_id = "<?php if (!empty($page_id)) {
            echo $page_id;
        }?>";
        $("#user_id").select2();

        $("#tabs").tabs();
        var editor = KindEditor.create('textarea[name="content"]', {
            uploadJson: baseurl + 'index.php/manage/articleimg/editor_upload_img?type=articles&article_id=' + article_id,
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });

        $("#subForm1").click(function () {
            var title = $("#title").val();
            if (title == '') {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "报表标题必须填写。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return;
            }
            $("#from1").submit();
        });
    });
</script>
</body>
</html>
